<div class="ibox">
	<div class="ibox-content">
		<form class="form-horizontal" id="addForm" action="${cxt!}/message/emailMessage/add" method="POST" >
			<div class="form-group">
				<label for="namebasic" class="col-md-2 control-label">${_res["emailMessage.emailTitle"]}
					<span class="fontColorRed">&nbsp;*</span>
				</label>
				<div class="col-md-8">
					<input type="text" class="form-control" name="emailMessage.title" placeholder="${_res['emailMessage.emailTitle']}" required aria-required="true">
				</div>
			</div>
			<div class="hr-line-dashed"></div>

			<!--sky update start-->
			
			<div class="form-group">
				<label for="namebasic" class="col-md-2 control-label">${_res["emailMessage.sendObject"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-md-8">
					<#dict type="select" id="example-collapse" multiple="multiple"  empty="false" table="customer_role" filedName="name" filedValue="id"  />
					<input type="hidden" name="emailMessage.sendobject" id="sendObject" required="true">
				</div>
				
			</div>
			
			<div class="hr-line-dashed"></div>
			
			<!--sky update end-->
			
			<div class="form-group">
				<label class="col-md-2 control-label">${_res["emailMessage.sendTime"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-md-3">
					<input class="form-control layer-date laydate-icon" name="emailMessage.sendtime" placeholder="${_res['emailMessage.sendTime']}" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" required aria-required="true" />
				</div>
				
				<label class="col-md-2 control-label">${_res["emailMessage.isHypertext"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-md-3">
					<#dict type="radio" name="emailMessage.ishtml" dictCode="COMMON_YN" defaultValue="Y" />
				</div>
			</div>
			<div class="hr-line-dashed"></div>
				
				
			<div class="form-group">
			
				<div class="row">
					<div class="col-md-10 m-l-xl">
						<a href="javascript:void(0)" id="uploadDatumFile" class="btn btn-info btn-sm">${_res["emailMessage.addAttachments"]}</a>
						<input type="file" style="display:none" id="file_uploadDatumFile" name="attachment" />
					</div>
				</div>
				
				<div class="row m-t-md">
					<div id="uploadproimgfiles" class="col-md-10 m-l-xl">
						<!-- ajax片段开始  -->
						<% #ajax uploadproimgfiles: { 
							if(uploadFile! != null) { %>
								<div class="bg-success p-l-md p-r-md disIB bordeRadius4px m-l-sm m-r-sm">
									<input type="hidden" name="emailAttachment.path"   value="${uploadFile.path!}"/>
									<input type="hidden" name="emailAttachment.originalfilename"   value="${uploadFile.originalFileName!}"/>
									${uploadFile.originalFileName!}<a href="#" onclick="removeFile(this);"><i class="fa fa-times"></i></a>
								</div> 
							<%}  
						} %> 
						<!-- ajax片段结尾 -->
					</div>
				</div>
				
			</div>
					
					
			<div class="hr-line-dashed"></div>
			<label class=" control-label">${_res["emailMessage.emailContent"]}<span class="fontColorRed">&nbsp;*</span></label>
			<script id="container" name="emailMessage.content" type="text/plain" style="width:100%; min-height:300px !important"></script>
			 
		    <div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<div class="row">
					<div class="col-md-10 col-md-offset-2">
						<button type="button" class="btn btn-warning" onClick="ajaxContent('/message/emailMessage/list')">${_res["system.return"]}</button>
						<button type="submit" class="btn btn-primary">${_res["system.save"]}</button>
						<button type="button" class="btn btn-danger" onClick="ajaxContent('/message/emailMessage/list')">${_res["system.cancel"]}</button>
					</div>
				</div>
			</div>
		</form>
	</div>
</div>
<#submit formId="addForm" divId="content" /> 
<#nav />

<script>
	$(document).ready(function() {
		//初始化富文本编辑框
		var editor = new UE.ui.Editor();  
	    editor.render("container");
		
		/*添加附件功能 */
		$("a[id^='upload']").on('click', function() {
			var id = $(this).attr("id");
			$("#file_" + id).click();
		});
		
		// 选择文件之后执行上传ajaxMultiFileUpload(divId,fileElementId,toUrl,uploadFolder,uploadFiles,callback)
		$("input[id^='file_upload']").on("change", function() {
			var fileElementId = $(this).attr("id");
			ajaxMultiFileUpload("uploadproimgfiles",fileElementId,"/message/emailMessage/add.html#uploadproimgfiles","email"); 
		});
	});
	
	function removeFile(norTr) {
		$(norTr).parent().remove();
	}
	

	//multiselect
    $(document).ready(function() {
    	var multiArrs = new Array();
        $('#example-collapse').multiselect({
        	buttonWidth: '730px',
        	numberDisplayed: 8,
        	includeSelectAllOption: true,
        	onSelectAll: function(checked) {
        		if(checked === true){
	        		$('#example-collapse').each(function(){
	        		    $("#sendObject").val($(this).val());
	        		 });
        		}else if (checked === false) {
        			$("#sendObject").val("");
            	}
        		
        	},
            onChange: function(element, checked) {
            	if(checked === true){
            		multiArrs.push(element.val());
            	}else if (checked === false) {
            		multiArrs.remove(element.val());
            	}
            	$("#sendObject").val(multiArrs.join(","));
                
            }
        });
        
    });

</script>